In this project, the open-source R programming language is used to model the progression in the COVID-19 pandemic in different U.S. counties. R is maintained by an international team of developers who make the language available at The Comprehensive R Archive Network. Readers interested in reusing our code and reproducing our results should have R installed locally on their machines. R can be installed on a number of different operating systems (see Windows, Mac, and Linux for the installation instructions for these systems). We also recommend using the RStudio interface for R. The reader can download RStudio for free by following the instructions at the link. For non-R users, we recommend the Hands-on Programming with R for a brief overview of the software’s functionality. Hereafter, we assume that the reader has an introductory understanding of the R programming language.
In the code chunk below, we load the packages used to support our analysis. Note that the code of this and any of the code chunks can be hidden by clicking on the ‘Hide’ button to facilitate the navigation.
if(require(pacman)==FALSE) install.packages("pacman") # check to see if the pacman package is installed; if not install it
if(require(devtools)==FALSE) install.packages("devtools") # check to see if the devtools package is installed; if not install it
# to check and install if these packages are not found locally on machine
if(require(albersusa)==FALSE) devtools::install_github('hrbrmstr/albersusa') #install package if needed
if(require(albersusa)==FALSE) devtools::install_github('dreamRs/r2d3maps') #install package if needed
# check if packages are not installed; if yes, install missing packages
pacman::p_load(tidyverse, magrittr, dataPreparation, recipes, doParallel, psych, skimr, VIM, reshape2, # for data analysis
COVID19, rvest, readxl, # to get county level COVID19 data, scrape Wikipedia, and load xls files
DT, stargazer, # used for having nicely formatted outputs in Markdown
zoo, fpp2, dtwclust, factoextra, TSclust, proxy, NbClust, # for TS analysis and clustering
DataExplorer, scales, ggdendro, gridExtra, RColorBrewer, raster, GGally,# for plotting
leaflet, webshot, albersusa, tigris, plotly, r2d3maps,# for mapping
caret, caretEnsemble, AUC, caTools, DMwR, MLmetrics, # ML packages
rpart, nnet, naivebayes, # rpart, nnet, and multinom packages
conflicted)
# Handling conflicting function names from packages
conflict_prefer('combine', 'dplyr') # Preferring dplyr::combine over any other package
conflict_prefer('select', "dplyr") #Preferring dplyr::select over any other package
conflict_prefer("summarize", "dplyr") # similar to above but with dplyr::summarize
conflict_prefer("filter", "dplyr") # Preferring filter from dplyr
conflict_prefer("dist", "stats") # Preferring dist from stats
conflict_prefer("as.dist", "stats") # Preferring as.dist from stats
set.seed(2020) # to assist with reproducibility
sInfo = sessionInfo()
For our analysis, we fuse data from multiple sources. We describe the process of obtaining and merging each of these sources in the subsections below.
In this section, we utilize the COVID19 package to obtain the following information: (Guidotti & Ardia, 2020)
From this information, we have also computed the new daily and weekly confirmed cases/deaths per county. The data is stored in a tidy format, but can be expanded to a wide format using pivot_wider() from the tidyverse package.
counties = covid19(country = "US",
level = 3, # for county
start = "2020-03-01", # First Sunday in March
end = "2020-10-24", # end Date
raw = FALSE, # to ensure that all counties have the same grid of dates
amr = NULL, # we are not using the apple mobility data for our analysis
gmr = NULL, # we are not using the Google mobility data for our analysis
wb = NULL, # world bank data not helpful for county level analysis
verbose = FALSE)
counties %<>% # next line removes non-contiguous US states/territories
filter(!administrative_area_level_2 %in% c('Alaska', 'Hawaii', 'Puerto Rico', 'Northern Mariana Islands', 'Virgin Islands')) %>%
fastFilterVariables(verbose = FALSE) %>% #dropping invariant columns or bijections
filter(!is.na(key_numeric)) %>% # these are not counties
group_by(id) %>% # grouping the data by the id column to make computations correct
arrange(id, date) %>% # to ensure correct calculations
mutate(day = wday(date, label = TRUE) %>% factor(ordered = F), # day of week
newCases = c(NA, diff(confirmed)), # computing new daily cases per county
newDeaths = c(NA, diff(deaths)) ) # computing new daily deaths per county
# manually identifying factor variables
factorVars = c("school_closing", "workplace_closing", "cancel_events",
"gatherings_restrictions", "transport_closing", "stay_home_restrictions",
"internal_movement_restrictions", "international_movement_restrictions",
"information_campaigns", "testing_policy", "contact_tracing")
counties %<>% # converting those variables into character and then factor
mutate_at(.vars = vars(any_of(factorVars)), .funs = as.character) %>%
mutate_at(.vars = vars(any_of(factorVars)), .funs = as.factor)
cat(paste0("At this stage, we have only read the data based on the covid package. The resulting data is stored at an object titled counties, which contains ", nrow(counties), " observations and ",
ncol(counties), " variables. Note that we have filtered observations that do not have a numeric key and removed some columns that do not add any value to future analysis (e.g., invariant cols)."))
At this stage, we have only read the data based on the covid package. The resulting data is stored at an object titled counties, which contains 739704 observations and 24 variables. Note that we have filtered observations that do not have a numeric key and removed some columns that do not add any value to future analysis (e.g., invariant cols).
In the code chunk below, we merge our counties’ COVID data with seven additional datasets:
Rural/ Underserved Counties: From the Consumer Financial Protection Bureau, we have obtained the Final 2020 List titled: Rural or underserved counties. Per the website, the procedure for determining the classification of a county is as follows: “Beginning in 2020, the rural or underserved counties lists use a methodology for identifying underserved counties described in the Bureau’s interpretive rule: Truth in Lending Act (Regulation Z); Determining “Underserved” Areas Using Home Mortgage Disclosure Act Data.”
Based on the US Census Data, we extracted the land area in square miles for each county, which we combined with population to compute each county’s population density, which we hypothesize to be predictive of hotspots for COVID transmission based on the available COVID-19 literature.
Based on Data & Lab (2018), we have obtained the voting results for all counties in the 2016 Presidential elections. The data was used to compute the percentage of total votes that went to President Trump, with the underlying hypothesis that the politicization of COVID response (e.g., perception/willingness to use face masks, policies and the population’s reaction to the disease) may be explained by party affiliation.
Based on Wikipedia’s Table of State Governors (click for permanent link to the version we scraped), we scraped the Governor’s party affiliation since we hypothesized that it may impact the type of policies used on a state-level. Given that the District of Columbia does not have a governor, when we merged out results back to the counties data frame, we knew (and confirmed) that this would result in NAs. These were the only NAs in that merged column, which we imputed with “Democratic” since D.C.’s Mayor is a Democrat.
Based on the following Kaiser Health News Webpage, we extracted by county information on: (a) number of ICU beds per 10,000 residents; (b) percent of population aged 60+; and (c) number of ICU beds per 10,000 60+aged residents.
We have also engineered a region variable based on the CDC’s 10 Regions Framework. While geographic regions are hypothesized to be a factor in disease outbreaks, we chose to utilize the CDC regions specifically based on the following explanation from the aforementioned link:
> “CDC’s National Center for Chronic Disease Prevention and Health Promotion (NCCDPHP) is strengthening the consistency and quality of the guidance, communications, and technical assistance provided to states to improve coordination across our state programs”
Based on the Census’s Small Area Income and Poverty Estimates (SAIPE) Program, we extracted the estimate for the percent of population in poverty. The estimate is based on 2018 data (released in December 2019). At the time of the start of our analysis, these estimates were the most up to date publicly available data.
# [A] Rural or Urban Classification of the County
ru = read.csv("https://www.consumerfinance.gov/documents/8911/cfpb_rural-underserved-list_2020.csv")
ru %<>% transmute(key_numeric = FIPS.Code, #renaming FIPS.Code to key_numeric
countyType = "Rural/Underserved") # creates two vars and drop old vars
counties = merge(counties, ru, by = "key_numeric", all.x = TRUE) # merging the data back to counties
counties$countyType %<>% replace_na("Other") # for any county not in the Consumer FIN data replace NA by Other
# [B] Population Density of Each County
download.file("https://www2.census.gov/library/publications/2011/compendia/usa-counties/excel/LND01.xls",
destfile = "../Data/LND01.xls", mode = "wb") # downloading Land Area Data Per the 2010 Census
areas = read_excel("../Data/LND01.xls") %>% # reading the Excel file
select(STCOU, LND110210D) #selecting only the FIPS and the Land Area from the 2010 Census variables
colnames(areas) = c("key_numeric", "LandAreaSqMiles2010") # Renaming the columns
areas$key_numeric %<>% as.numeric() # to remove leading 0
counties = merge(counties, areas, by ="key_numeric", all.x = TRUE) # adding the area to data frame
counties$popDensity = counties$population / counties$LandAreaSqMiles2010 # creating the population density variable
counties %<>% select(-c(population, LandAreaSqMiles2010)) #dropping two variables used in creating pop density
# [C] 2016 Presidential Elections County Data from Harvard https://doi.org/10.7910/DVN/VOQCHQ
elections = read.csv("../Data/countypres_2000-2016.csv") %>% # reading the downloaded CSV
filter(year == 2016 & party == "republican") %>% # just keeping data for recent election and republican votes
mutate(key_numeric = FIPS, # renaming FIPS to key_numeric
percRepVotes = 100*(candidatevotes/totalvotes) ) %>% # computing percent of republican votes (from total votes)
select(key_numeric, percRepVotes) # keeping only the key and variable used in merge
counties %<>% merge(elections, by = "key_numeric", all.x = TRUE) # merge with the counties data
# [D] Party of State Governor
stateGovernor = "https://en.wikipedia.org/w/index.php?title=List_of_United_States_governors&oldid=977828843" %>%
read_html() %>% html_node("table:nth-child(9)") %>% html_table(header = 2, fill = TRUE) # scraping data
colnames(stateGovernor) = stateGovernor[1,] # making first row to be the header
stateGovernor = stateGovernor[-1, c(1,5)] # dropping first row
stateGovernor$Party %<>% str_replace('Democratic–Farmer–Labor', 'Democratic') #replacing Democratic–Farmer–Labor w/ Democratic
stateGovernor$Party %<>% str_replace('Republican[note 1]', 'Republican') #replacing Republican[note 1] w/ Republican
colnames(stateGovernor) = c('administrative_area_level_2', 'governorsParty') # renaming columns
counties %<>% merge(stateGovernor, by = 'administrative_area_level_2', all.x = TRUE) # merge
counties$governorsParty %<>% replace_na("Democratic") # 203 NAs are for District of Columbia which has a Democratic Mayor
# [E] Kaiser Health News Data on the County Level
hospitals = read.csv("../Data/data-FPBfZ.csv") %>% # downloaded from KHN on 2020-10-26 (~9:30 pm EDT)
transmute(State = State, # keeping the State Variable | transmute drops variables that are not in call
County = County, # keeping the County Variable
PercentSeniors = Percent.of.Population.Aged.60., # Shortening Original Variable Name
icuBedsPer10000Residents = 10000 * (ICU.Beds/Total.Population), # Computing icuBedsPer10000Residents
icuBedsPer10000Seniors = 10000 * ICU.Beds/Population.Aged.60.) # Computing icuBedsPer10000Seniors
counties %<>% merge(hospitals, by.x = c("administrative_area_level_2", "administrative_area_level_3"),
by.y = c("State", "County"), all.x = TRUE) # merging the variables into counties based on two keys
# [F] CDC Regions for Each State
regionsCDC = data.frame(States = c('Connecticut', 'Maine', 'Massachusetts', 'New Hampshire', 'Rhode Island' ,
'Vermont', 'New York', # End of Region A
'Delaware', 'District of Columbia', 'Maryland', 'Pennsylvania',
'Virginia', 'West Virginia', 'New Jersey', # End of Region B
'North Carolina', 'South Carolina', 'Georgia', 'Florida', # Region C
'Kentucky', 'Tennessee', 'Alabama', 'Mississippi', # Region D
'Illinois', 'Indiana', 'Michigan', 'Minnesota', 'Ohio',
'Wisconsin', # End of Region E
'Arkansas', 'Louisiana', 'New Mexico', 'Oklahoma', 'Texas', # Region F
'Iowa', 'Kansas', 'Missouri', 'Nebraska', # Region G
'Colorado', 'Montana', 'North Dakota', 'South Dakota',
'Utah', 'Wyoming', # End of Region H
'Arizona', 'California', 'Hawaii', 'Nevada', # Region I
'Alaska', 'Idaho', 'Oregon', 'Washington' # Region J
),
regions = c(rep('Region.A', 7), rep('Region.B', 7), rep('Region.C', 4),
rep('Region.D', 4), rep('Region.E', 6), rep('Region.F', 5),
rep('Region.G', 4), rep('Region.H', 6), rep('Region.I', 4),
rep('Region.J', 4) ) )
counties %<>% merge(regionsCDC, by.x = 'administrative_area_level_2', by.y = 'States', all.x = TRUE) # merge
# [G] Poverty Estimates
download.file("https://www2.census.gov/programs-surveys/saipe/datasets/2018/2018-state-and-county/est18all.xls",
destfile = "../Data/est18all.xls", mode = "wb") # downloading the data for poverty estimates (latest 2018)
poverty = read_excel("../Data/est18all.xls", skip = 3) %>% # reading the data in R
transmute(key_numeric = paste0(`State FIPS Code`, `County FIPS Code`) %>% as.numeric, # creating the key from two variables
povertyPercent = as.numeric(`Poverty Percent, All Ages`) ) # shortening povertyPercent Variable's Name
counties = merge(counties, poverty, by = "key_numeric", all.x = TRUE) # merge
# Final Transformations before Saving the Counties Data
counties %<>% group_by(id) # Needs to be regrouped again after all the merge steps
counties %<>% mutate_at(.vars = c('governorsParty', 'regions'), as.factor) # converting the two vars to factor
# Saving the data into an RDS file
saveRDS(counties, paste0("../Data/counties.rds"))
# Showing a glimpse of the counties data
glimpse(counties)
## Rows: 739,704
## Columns: 32
## Groups: id [3,108]
## $ key_numeric <int> 1001, 1001, 1001, 1001, 1001, 1...
## $ administrative_area_level_2 <chr> "Alabama", "Alabama", "Alabama"...
## $ administrative_area_level_3 <chr> "Autauga", "Autauga", "Autauga"...
## $ id <chr> "fe5db3f0", "fe5db3f0", "fe5db3...
## $ date <date> 2020-05-17, 2020-06-27, 2020-0...
## $ confirmed <int> 110, 498, 1030, 120, 212, 168, ...
## $ deaths <int> 4, 12, 21, 4, 3, 3, 0, 11, 21, ...
## $ school_closing <fct> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3...
## $ workplace_closing <fct> 3, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2...
## $ cancel_events <fct> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2...
## $ gatherings_restrictions <fct> 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3...
## $ transport_closing <fct> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
## $ stay_home_restrictions <fct> 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2...
## $ internal_movement_restrictions <fct> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2...
## $ international_movement_restrictions <fct> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3...
## $ information_campaigns <fct> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2...
## $ testing_policy <fct> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3...
## $ contact_tracing <fct> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2...
## $ stringency_index <dbl> 72.69, 68.98, 67.13, 72.69, 72....
## $ key_google_mobility <chr> "Alabama, Autauga County", "Ala...
## $ day <fct> Sun, Sat, Sat, Mon, Fri, Mon, S...
## $ newCases <int> 0, 10, 15, 10, 7, 9, 0, 10, 13,...
## $ newDeaths <int> 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0...
## $ countyType <chr> "Other", "Other", "Other", "Oth...
## $ popDensity <dbl> 93.98594, 93.98594, 93.98594, 9...
## $ percRepVotes <dbl> 72.76659, 72.76659, 72.76659, 7...
## $ governorsParty <fct> Republican, Republican, Republi...
## $ PercentSeniors <dbl> 19.1, 19.1, 19.1, 19.1, 19.1, 1...
## $ icuBedsPer10000Residents <dbl> 1.090196, 1.090196, 1.090196, 1...
## $ icuBedsPer10000Seniors <dbl> 5.701796, 5.701796, 5.701796, 5...
## $ regions <fct> Region.D, Region.D, Region.D, R...
## $ povertyPercent <dbl> 13.8, 13.8, 13.8, 13.8, 13.8, 1...
In this section, we provide the results of some of the exploratory analysis that we have performed on the data obtained from the multiple sources. Given that a large part of this exploratory analysis was performed outside of R (using Tableau), we do not provide any code for the visualizations. Note that the base code for the visualizations performed in R can be obtained from the following GitHub Repo.
To prepare the counties data for time-series clustering, we have made the following transformations:
newCases variable within the counties data frame using a 7-day moving average, which would also account for the daily patterns seen in the data (i.e., e.g., smaller number of reported cases over the weekend, etc.). The resulting data was stored in a variable titled newMA7;newMA7 variable such that its values vary between 0 and 1. When the values equals to 1, this denotes that the county is experiencing its maximum newMA7 confirmed cases over our study period;wide data format needed for time series clustering implementations; andclusteringPrep = counties %>% # from the counties
select(id, date, key_google_mobility, newCases) %>% # selecting minimal amount of cols for visual inspection
arrange(id, date) %>% # arranged to ensure correct calculations
mutate(newMA7 = rollmeanr(newCases, k = 7, fill = NA), # 7-day ma of new (adjusted) cases
maxMA7 = max(newMA7, na.rm = T), # obtaining the max per county to scale data
scaledNewMA7 = pmax(0, newMA7/maxMA7, na.rm = TRUE) ) %>% # scaling data to a 0-1 scale by county
select(id, key_google_mobility, date, scaledNewMA7) %>% # dropping newCases
pivot_wider(names_from = date, values_from = scaledNewMA7) # converting the data to a wide format
constantColumns = whichAreConstant(clusteringPrep, verbose = F) # identifying constant columns
paste0(c('The following dates were removed from our data frame since the scaledNEWMA7 variable was constant across all counties: ',
colnames(clusteringPrep)[constantColumns]), collapse = ' ')
## [1] "The following dates were removed from our data frame since the scaledNEWMA7 variable was constant across all counties: 2020-03-01 2020-03-02 2020-03-03 2020-03-04 2020-03-05 2020-03-06 2020-03-07"
clusteringPrep %<>% select(-all_of(constantColumns) ) %>% # speeds up clustering by dec length of series
as.data.frame() # data needs to be data frame for clustering
row.names(clusteringPrep) = clusteringPrep[,1] # needed for tsclust
clusteringPrep = clusteringPrep[,-1] # dropping the id column since it is now row.name
One of the primary objectives of this paper is to examine how the scaled and smoothed time series of daily new cases (i.e., our scaledNewMA7 variable) per county can be grouped. Well, there has been some signs of a possible ‘first wave’ and ‘second wave’ if one were to examine the number of new cases per day for the entire US (e.g., see this USAFACTS Chart). From our examination of a sample of individual counties on the same website, it was not clear that this pattern was indeed reflected on the county level. For example, if we were to examine the visualization for the number of new known cases per day for Kings County, New York, there is limited evidence for any second wave. Hence, in this section, we attempt to examine how the individual counties can be grouped based on their scaledNewMA7 time-series.
It is important to note that, in our estimation, there are three important decisions to be made when performing time-series clustering:
In our preliminary analysis, we will limit the clustering to the state of Connecticut since it only contains 8 counties. Here, we will apply some common distance measures to the scaledNewMA7 and apply hierarchical clustering for each Connecticut county to examine the suitability of the different measures based on a visual inspection of the clusters and their associated dendogram.
ctPrep = clusteringPrep %>% filter(str_detect(key_google_mobility, "Connecticut")) # subsetting to only CT data
row.names(ctPrep) = ctPrep$key_google_mobility %>%
str_remove_all("Connecticut, ") %>%
str_remove_all(" County") # given that we have only one state, we can use just the county name for row names
ctPrep = ctPrep[,-1] # dropping the key_google_moblity column from the data
pr_DB$set_entry(FUN = diss.ACF, names = c("ACFD"),
loop = TRUE, type = "metric", distance = TRUE,
description = "Autocorrelation-based distance") # specifying the distance function based on proxy package
dACF = tsclust(ctPrep, type = "hierarchical", k=2L, distance = "ACFD",
preproc = NULL, seed = 2020) # hierarchical clustering based on the ACFD distance
hclus = cutree(dACF, k = 2) %>% # using a cut tree of 2 to see the order by which counties are grouped
as.data.frame(.) %>%
rename(.,cluster_group = .) %>%
rownames_to_column("County")
hcdata = dendro_data(dACF)
names_order = hcdata$labels$label
p1 = hcdata %>%
ggdendrogram(., rotate=TRUE, leaf_labels=FALSE)
p2 = ctPrep %>%
rownames_to_column(var = "County") %>%
pivot_longer(cols = starts_with("2020"), names_to = "Date") %>%
full_join(., hclus, by = "County") %>%
mutate(cluster_group = as.factor(cluster_group)) %>%
mutate(County = factor(County, levels = rev(as.character(names_order)))) %>%
ggplot(aes(x = Date, y = value, colour = cluster_group, group = County)) +
geom_line()+
facet_wrap(~County, ncol = 1, strip.position="left") +
guides(color=FALSE) +
theme_bw() +
theme(strip.background = element_blank(), strip.text = element_blank())
gp1 = ggplotGrob(p1)
gp2 = ggplotGrob(p2)
grid.arrange(gp2, gp1, ncol=2, widths=c(4,2))
pr_DB$set_entry(FUN = diss.COR, names = c("Cor"),
loop = TRUE, type = "metric", distance = TRUE,
description = "Pearson Correlation-based distance")
cor = tsclust(ctPrep, type = "hierarchical", k=2L, distance = "Cor",
preproc = NULL, seed = 2020)
hclus = cutree(cor, k = 2) %>%
as.data.frame(.) %>%
rename(.,cluster_group = .) %>%
rownames_to_column("County")
hcdata = dendro_data(cor)
names_order = hcdata$labels$label
p1 = hcdata %>%
ggdendrogram(., rotate=TRUE, leaf_labels=FALSE)
p2 = ctPrep %>%
rownames_to_column(var = "County") %>%
pivot_longer(cols = starts_with("2020"), names_to = "Date") %>%
full_join(., hclus, by = "County") %>%
mutate(cluster_group = as.factor(cluster_group)) %>%
mutate(County = factor(County, levels = rev(as.character(names_order)))) %>%
ggplot(aes(x = Date, y = value, colour = cluster_group, group = County)) +
geom_line()+
facet_wrap(~County, ncol = 1, strip.position="left") +
guides(color=FALSE) +
theme_bw() +
theme(strip.background = element_blank(), strip.text = element_blank())
gp1 = ggplotGrob(p1)
gp2 = ggplotGrob(p2)
grid.arrange(gp2, gp1, ncol=2, widths=c(4,2))
dtw = tsclust(ctPrep, type = "hierarchical", k=2L, distance = "dtw", preproc = NULL, seed = 2020)
hclus = cutree(dtw, k = 2) %>%
as.data.frame(.) %>%
rename(.,cluster_group = .) %>%
rownames_to_column("County")
hcdata = dendro_data(dtw)
names_order = hcdata$labels$label
p1 = hcdata %>%
ggdendrogram(., rotate=TRUE, leaf_labels=FALSE)
p2 = ctPrep %>%
rownames_to_column(var = "County") %>%
pivot_longer(cols = starts_with("2020"), names_to = "Date") %>%
full_join(., hclus, by = "County") %>%
mutate(cluster_group = as.factor(cluster_group)) %>%
mutate(County = factor(County, levels = rev(as.character(names_order)))) %>%
ggplot(aes(x = Date, y = value, colour = cluster_group, group = County)) +
geom_line()+
facet_wrap(~County, ncol = 1, strip.position="left") +
guides(color=FALSE) +
theme_bw() +
theme(strip.background = element_blank(), strip.text = element_blank())
gp1 = ggplotGrob(p1)
gp2 = ggplotGrob(p2)
grid.arrange(gp2, gp1, ncol=2, widths=c(4,2))
pr_DB$set_entry(FUN = diss.EUCL, names = c("EUCL"),
loop = TRUE, type = "metric", distance = TRUE,
description = "Euclidean-based distance")
eucl = tsclust(ctPrep, type = "hierarchical", k=2L, distance = "EUCL",
preproc = NULL, seed = 2020)
hclus = cutree(eucl, k = 2) %>%
as.data.frame(.) %>%
rename(.,cluster_group = .) %>%
rownames_to_column("County")
hcdata = dendro_data(eucl)
names_order = hcdata$labels$label
p1 = hcdata %>%
ggdendrogram(., rotate=TRUE, leaf_labels=FALSE)
p2 = ctPrep %>%
rownames_to_column(var = "County") %>%
pivot_longer(cols = starts_with("2020"), names_to = "Date") %>%
full_join(., hclus, by = "County") %>%
mutate(cluster_group = as.factor(cluster_group)) %>%
mutate(County = factor(County, levels = rev(as.character(names_order)))) %>%
ggplot(aes(x = Date, y = value, colour = cluster_group, group = County)) +
geom_line()+
facet_wrap(~County, ncol = 1, strip.position="left") +
guides(color=FALSE) +
theme_bw() +
theme(strip.background = element_blank(), strip.text = element_blank())
gp1 = ggplotGrob(p1)
gp2 = ggplotGrob(p2)
grid.arrange(gp2, gp1, ncol=2, widths=c(4,2))
proxy::pr_DB$set_entry(FUN = diss.PER, names = c("Per"),
loop = TRUE, type = "metric", distance = TRUE,
description = "Periodogram-based distance")
perD = tsclust(ctPrep, type = "hierarchical", k=2L, distance = "Per",
preproc = NULL, seed = 2020)
hclus = cutree(perD, k = 2) %>%
as.data.frame(.) %>%
rename(.,cluster_group = .) %>%
rownames_to_column("County")
hcdata = dendro_data(perD)
names_order = hcdata$labels$label
p1 = hcdata %>%
ggdendrogram(., rotate=TRUE, leaf_labels=FALSE)
p2 = ctPrep %>%
rownames_to_column(var = "County") %>%
pivot_longer(cols = starts_with("2020"), names_to = "Date") %>%
full_join(., hclus, by = "County") %>%
mutate(cluster_group = as.factor(cluster_group)) %>%
mutate(County = factor(County, levels = rev(as.character(names_order)))) %>%
ggplot(aes(x = Date, y = value, colour = cluster_group, group = County)) +
geom_line()+
facet_wrap(~County, ncol = 1, strip.position="left") +
guides(color=FALSE) +
theme_bw() +
theme(strip.background = element_blank(), strip.text = element_blank())
gp1 = ggplotGrob(p1)
gp2 = ggplotGrob(p2)
grid.arrange(gp2, gp1, ncol=2, widths=c(4,2))
Based on the preliminary analysis, the Euclidean distance seems appropriate for our analysis. Therefore, in our full analysis, we will use the Euclidean distance with the \(k\)-means approach as explained earlier in this section.
clusteringPrep %<>% select(-c(key_google_mobility)) # removing this variable so we can cluster
nc = NbClust(clusteringPrep, distance = "euclidean", # euclidean distance
min.nc = 2, max.nc = 50, # searching for optimal k between k=2 and k=50
method = "kmeans", # using the k-means method
index = "all") # using 26 of the 30 indices in the package
## *** : The Hubert index is a graphical method of determining the number of clusters.
## In the plot of Hubert index, we seek a significant knee that corresponds to a
## significant increase of the value of the measure i.e the significant peak in Hubert
## index second differences plot.
##
## *** : The D index is a graphical method of determining the number of clusters.
## In the plot of D index, we seek a significant knee (the significant peak in Dindex
## second differences plot) that corresponds to a significant increase of the value of
## the measure.
##
## *******************************************************************
## * Among all indices:
## * 7 proposed 2 as the best number of clusters
## * 2 proposed 3 as the best number of clusters
## * 8 proposed 4 as the best number of clusters
## * 1 proposed 5 as the best number of clusters
## * 1 proposed 7 as the best number of clusters
## * 1 proposed 29 as the best number of clusters
## * 1 proposed 36 as the best number of clusters
## * 1 proposed 43 as the best number of clusters
## * 1 proposed 50 as the best number of clusters
##
## ***** Conclusion *****
##
## * According to the majority rule, the best number of clusters is 4
##
##
## *******************************************************************
kclus = nc$Best.partition %>% as.data.frame() %>% #obtaining the best partition/ cluster assignment for optimal k
rename(., cluster_group = .) %>% rownames_to_column("County")
#converting the wide to tall data and adding the cluster groupings
clusters = clusteringPrep %>%
rownames_to_column(var = "County") %>%
pivot_longer(cols = starts_with("2020"), names_to = "Date") %>%
inner_join(., kclus, by = "County") %>%
mutate(cluster_group = as.factor(cluster_group))
idClusters = clusters %>% select(c(County, cluster_group)) # creating a look-up table of county and cluster group
colnames(idClusters) = c('id', 'cluster_group') # renaming the columns
idClusters %<>% unique() #removing the duplicates due to different dates (we had that to ensure that the clustering was applied correctly)
# Adding Cluster Grouping to a subset of the counties data frame, which we will use for explanatory modeling
clusterCounties = counties %>%
select(c(id, key_numeric, administrative_area_level_2, administrative_area_level_3,
countyType, popDensity, percRepVotes, governorsParty, PercentSeniors,
icuBedsPer10000Residents, regions, povertyPercent)) %>%
inner_join(., idClusters, by ='id') %>%
unique()
saveRDS(clusterCounties, '../Data/clusterCounties.rds')
In this subsection, we provide six sets of plots:
All plots can be accessed by toggling through the tabsets below. Note that the third tabs contains subtabs (one for each cluster).
# Obtaining the counties with max population density per cluster in addition to three counties were the authors
# resided (as a sanity check) and the Navajo County in Arizona where COVID outbreaks were reported
PopDensities = clusterCounties %>% ungroup() %>% group_by(cluster_group) %>%
summarise(pd = max(popDensity, na.rm = T))
indices = c(which(clusterCounties$popDensity %in% PopDensities$pd),
which(clusterCounties$key_numeric%in% c(1081, 17119, 39017, 4017)) )
# creating a lookup data frame
lookupDF = clusterCounties[indices, c('id', 'cluster_group')]
# Obtaining national data
usAggregate = covid19(country = 'US', level = 1,
start = '2020-03-01', end = '2020-10-24',
verbose = FALSE)
usAggregate %<>% select(id, key_google_mobility, date, confirmed) %>%
mutate(newCases = c(NA, diff(confirmed)),
newMA7 = rollmeanr(newCases, k = 7, fill = NA), # 7-day ma of new (adjusted) cases
maxMA7 = max(newMA7, na.rm = T), # obtaining the max per county to scale data
scaledNewMA7 = pmax(0, newMA7/maxMA7, na.rm = TRUE))
sampleCounties = counties %>% # from the counties
filter(id %in% lookupDF$id) %>% # only the 8 counties of interest
select(id, date, key_google_mobility, newCases) %>% # selecting minimal amount of cols for visual inspection
arrange(id, date) %>% # arranged to ensure correct calculations
mutate(newMA7 = rollmeanr(newCases, k = 7, fill = NA), # 7-day ma of new (adjusted) cases
maxMA7 = max(newMA7, na.rm = T), # obtaining the max per county to scale data
scaledNewMA7 = pmax(0, newMA7/maxMA7, na.rm = TRUE) )
# Joining the US Data with the Sample Counties
sampleCountiesPlusUS = rbind(usAggregate, sampleCounties)
sampleCountiesPlusUS = left_join(sampleCountiesPlusUS, lookupDF, by = 'id')
sampleCountiesPlusUS$cluster_group %<>% as.character() %>% replace_na('Not Clustered') %>% as.factor()
sampleCountiesPlusUS$key_google_mobility %<>% recode(US = 'Aggregate for the Entire US')
colorPal = brewer.pal(n= levels(sampleCountiesPlusUS$cluster_group) %>% length(), 'Set2')
names(colorPal) = levels(sampleCountiesPlusUS$cluster_group)
# Facet Wrap Plot: nonScaledMotivationPlot
sampleCountiesPlusUS %>% ggplot(aes(x = date, y = newMA7, group = id, color = cluster_group)) +
geom_line(size = 1) +
facet_wrap(~ key_google_mobility, scales = 'free_y', ncol = 3) +
theme_bw(base_size = 11) +
theme(legend.position = 'none') +
labs(color = '', x = 'Month', y = 'New Cases By County') +
scale_color_manual(values = colorPal)
sampleCountiesPlusUS %>% ggplot(aes(x = date, y = scaledNewMA7, group = id, color = cluster_group)) +
geom_line(size = 1) +
facet_wrap(~ key_google_mobility, scales = 'free_y', ncol = 3) +
theme_bw(base_size = 11) +
theme(legend.position = 'none') +
labs(color = '', x = 'Month', y = 'New Cases By County') +
scale_color_manual(values = colorPal)
for (i in 1:length(levels(clusterCounties$cluster_group))) {
indexesForPlot = clusterCounties %>% filter(cluster_group %in% as.character(i)) %>%
pull(id) %>% sample(9) # pulling nine ids from each cluster
# Printing the tabs
cat(paste('#### Cluster', i, '{-} \n \n'))
# Subsetting and plotting the data
counties %>% # from the counties
select(id, date, newCases, key_google_mobility) %>% # selecting minimal columns
filter(id %in% indexesForPlot & !is.na(key_google_mobility)) %>% # selecting the rows of interest
left_join(clusterCounties[, c('id', 'cluster_group')], by = 'id') %>% # to get clusters
arrange(id, date) %>% # arranged to ensure correct calculations
mutate(newMA7 = rollmeanr(newCases, k = 7, fill = NA), # 7-day ma of new (adjusted) cases
maxMA7 = max(newMA7, na.rm = T), # obtaining the max per county to scale data
scaledNewMA7 = pmax(0, newMA7/maxMA7, na.rm = TRUE) ) %>%
ggplot(aes(x = date, y = scaledNewMA7, group = id, color = cluster_group)) +
geom_line(size = 1) +
facet_wrap(~ key_google_mobility, scales = 'free_y', ncol = 3) +
theme_bw(base_size = 11) +
theme(legend.position = 'none') +
labs(color = '', x = 'Month', y = 'New Cases By County', caption = paste0('Cluster: ', i)) +
scale_color_manual(values = colorPal) -> cplot
print(cplot) # to print out the graphs
cat('\n \n')
}
dfAvg = counties %>% # from the counties
select(id, date, newCases, key_google_mobility) %>% # selecting minimal columns
left_join(clusterCounties[, c('id', 'cluster_group')], by = 'id') %>% # to get clusters
arrange(id, date) %>% # arranged to ensure correct calculations
mutate(newMA7 = rollmeanr(newCases, k = 7, fill = NA), # 7-day ma of new (adjusted) cases
maxMA7 = max(newMA7, na.rm = T), # obtaining the max per county to scale data
scaledNewMA7 = pmax(0, newMA7/maxMA7, na.rm = TRUE) ) %>%
ungroup() %>% select(date, cluster_group, scaledNewMA7) %>%
group_by(date, cluster_group) %>%
summarise(Mean = mean(scaledNewMA7, na.rm= TRUE),
`First Quartile` = quantile(scaledNewMA7, probs = 0.25, na.rm= TRUE),
`Third Quartile` = quantile(scaledNewMA7, probs = 0.75, na.rm= TRUE))
# to have nice panels names but unfortunately will require a new colorPanel
levels(dfAvg$cluster_group) = paste('Cluster', levels(dfAvg$cluster_group))
colorPal2 = brewer.pal(n= levels(dfAvg$cluster_group) %>% length(), 'Set2')
names(colorPal2) = levels(dfAvg$cluster_group)
dfAvg %<>% pivot_longer(cols = c(`First Quartile`, Mean, `Third Quartile`),
names_to = 'Statistic')
dfAvg %>% ggplot(aes(x = date, y = value, color = cluster_group, linetype = Statistic)) +
geom_line(size = 1.25) +
scale_linetype_manual(values = c('dotted', 'solid', 'twodash')) +
facet_wrap(~ cluster_group, ncol = 2) +
theme_bw(base_size = 9.5) +
theme(legend.position = 'top') +
labs(color = '', x = 'Month', y = 'Quartiles of Scaled New Cases By Cluster By Day') +
scale_color_manual(values = colorPal2)
cty_sf = counties_sf("longlat") %>% # from albersusa package
filter(!state %in% c('Alaska', 'Hawaii'))
# ungrouping clusterCounties and selecting just the two variables needed for the clustering
LeafletCounties = clusterCounties %>% ungroup() %>%
dplyr::select(key_numeric, administrative_area_level_2, administrative_area_level_3, cluster_group, popDensity, povertyPercent)
colnames(LeafletCounties) = c('key_numeric', 'NAME_1', 'NAME_2', 'value', 'popDensity', 'povertyPercent')
# Converting the key_numeric to a proper FIPS_Code and then to a factor variable
LeafletCounties$key_numeric %<>% str_pad(width = 5, side = 'left', pad = '0') %>% as.factor()
LeafletCounties = cty_sf %>% geo_join(LeafletCounties, by_sp = "fips", by_df = "key_numeric")
# using same color scheme as the static one
myPal = colorFactor('Set2', domain = LeafletCounties$value, na.color = "white")
leaflet(height=500) %>% # initializing the leaflet map
setView(lng = -96, lat = 37.8, zoom = 3.8) %>% # setting the view on Continental US
addTiles() %>% # adding the default tiles
addPolygons(data = LeafletCounties, stroke = FALSE, fillColor = ~myPal(LeafletCounties$value), # adding the data
weight = 2, opacity = 1, color = "white", dashArray = "3", fillOpacity = 0.7, # adding color specs
popup = paste("County:", LeafletCounties$NAME_2, '<br>',
"Cluster #:", LeafletCounties$value, '<br>',
"Population Density:", round(LeafletCounties$popDensity, 1), '<br>',
"Poverty %:", round(LeafletCounties$povertyPercent, 1), '<br>')) %>% #pop-up Menu
addLegend(position = "bottomleft", pal = myPal, values = LeafletCounties$value,
title = "Cluster #", opacity = 1) # legend formatting
From both maps, some regional clustering of the counties can be seen (an interesting result since the clustering approach was only based on the scaled and smoothed time series of newly reported daily cases per county).
# Here we capitalized on the beautiful d3 maps (from the r2d3maps package) and the albersusa package for
# map projection to create a d3map and then capitalized on orca() from plotly to convert it into a
# well designed static plot
d3map = d3_map(shape = LeafletCounties, projection = "Albers", height = 500) %>%
add_discrete_scale(var = "value", palette = "Set2") %>%
add_legend(title = "Cluster #")
# saving output as a static png to be used in the paper
# Using the save_d3_png() function requires that you install the webshot package, as well as the
# phantom.js headless browser (which you can install using the function webshot::install_phantomjs()).
r2d3::save_d3_png(d3map, file = '../Figures/CountiesClustered.png', width = 1366, height = 768)
d3map # printing it out for the markdown
From both maps, some regional clustering of the counties can be seen (an interesting result since the clustering approach was only based on the scaled and smoothed time series of newly reported daily cases per county).
In the previous section, we showed that by using solely a scaled and smoothed time series of newly reported daily cases per county, the counties are grouped into three categories (whose time-series have distinct shapes based on the Euclidean distance measure). In this section, we attempt to model the factors that are associated with cluster assignment.
clusterCounties = readRDS('../Data/clusterCounties.rds')
multiClassData = ungroup(clusterCounties) # since we are no longer using the daily counts
multiClassData$countyType %<>% as.factor() # converting the variable countyType from char to factor
# Addressing a minor discrepancy in governorsParty (no impact on prior analysis since this is the first usage of that var)
# In Section 2.2, str_replace('Republican[note 1]', 'Republican') did not work due to []
multiClassData$governorsParty %<>% recode_factor(`Republican[note 1]` = 'Republican') # recoding factor level
multiClassData$governorsParty %<>% as.factor()
levels(multiClassData$cluster_group) = paste0('C', # making each factor level start with a string
levels(multiClassData$cluster_group) )
skim(multiClassData)
| Name | multiClassData |
| Number of rows | 3108 |
| Number of columns | 13 |
| _______________________ | |
| Column type frequency: | |
| character | 3 |
| factor | 4 |
| numeric | 6 |
| ________________________ | |
| Group variables | None |
Variable type: character
| skim_variable | n_missing | complete_rate | min | max | empty | n_unique | whitespace |
|---|---|---|---|---|---|---|---|
| id | 0 | 1 | 8 | 8 | 0 | 3108 | 0 |
| administrative_area_level_2 | 0 | 1 | 4 | 20 | 0 | 49 | 0 |
| administrative_area_level_3 | 0 | 1 | 3 | 20 | 0 | 1807 | 0 |
Variable type: factor
| skim_variable | n_missing | complete_rate | ordered | n_unique | top_counts |
|---|---|---|---|---|---|
| countyType | 0 | 1 | FALSE | 2 | Rur: 1596, Oth: 1512 |
| governorsParty | 0 | 1 | FALSE | 2 | Rep: 1756, Dem: 1352 |
| regions | 0 | 1 | FALSE | 10 | Reg: 524, Reg: 503, Reg: 412, Reg: 372 |
| cluster_group | 0 | 1 | FALSE | 4 | C3: 1037, C4: 907, C1: 849, C2: 315 |
Variable type: numeric
| skim_variable | n_missing | complete_rate | mean | sd | p0 | p25 | p50 | p75 | p100 | hist |
|---|---|---|---|---|---|---|---|---|---|---|
| key_numeric | 0 | 1.00 | 30671.83 | 14983.77 | 1001.00 | 19044.50 | 29212.00 | 46007.50 | 56045.00 | ▃▇▆▅▇ |
| popDensity | 1 | 1.00 | 369.63 | 6667.59 | 0.24 | 17.28 | 45.31 | 119.57 | 365169.38 | ▇▁▁▁▁ |
| percRepVotes | 1 | 1.00 | 63.30 | 15.65 | 4.09 | 54.48 | 66.35 | 74.92 | 96.03 | ▁▂▅▇▃ |
| PercentSeniors | 36 | 0.99 | 24.85 | 5.52 | 5.80 | 21.30 | 24.45 | 27.80 | 64.20 | ▁▇▂▁▁ |
| icuBedsPer10000Residents | 36 | 0.99 | 1.23 | 2.24 | 0.00 | 0.00 | 0.00 | 2.01 | 74.96 | ▇▁▁▁▁ |
| povertyPercent | 0 | 1.00 | 15.18 | 6.11 | 2.60 | 10.90 | 14.15 | 18.30 | 54.00 | ▆▇▂▁▁ |
multiClassData %>% select(-key_numeric) %>%
plot_bar(ncol = 2L, maxcat = 15L, ggtheme = theme_bw() )
multiClassData %>% select(-key_numeric) %>%
plot_boxplot(by = 'cluster_group', ncol = 2L,
ggtheme = theme_bw(),
geom_boxplot_args = list('outlier.shape' = 1))
na.omit(multiClassData) %>% select(-key_numeric) %>%
rename(icuBedsPer10kPpl = icuBedsPer10000Residents) %>% #shortened varName for plot
plot_correlation(ggtheme = theme_bw(), type = 'c') # plotting correlation among only continuous variables
As a final step in preparing our data, we have deleted all observations containing NAs and ungrouped the data frame. These steps are highlighted in the code chunk below. We then print a glimpse of our data to highlight that the number of observations changed when compared to the data skim provided in the previous subsection.
multiClassData %<>% na.omit() %>% ungroup()
glimpse(multiClassData)
## Rows: 3,071
## Columns: 13
## $ id <chr> "fe5db3f0", "1053d2dc", "f93077e9", "17...
## $ key_numeric <int> 1001, 1003, 1005, 1007, 1009, 1011, 101...
## $ administrative_area_level_2 <chr> "Alabama", "Alabama", "Alabama", "Alaba...
## $ administrative_area_level_3 <chr> "Autauga", "Baldwin", "Barbour", "Bibb"...
## $ countyType <fct> Other, Other, Rural/Underserved, Other,...
## $ popDensity <dbl> 93.98594, 140.41817, 27.89757, 35.96967...
## $ percRepVotes <dbl> 72.76659, 76.54571, 52.09667, 76.40322,...
## $ governorsParty <fct> Republican, Republican, Republican, Rep...
## $ PercentSeniors <dbl> 19.1, 26.3, 23.5, 21.1, 23.6, 22.6, 25....
## $ icuBedsPer10000Residents <dbl> 1.0901955, 2.5078678, 1.9083241, 0.0000...
## $ regions <fct> Region.D, Region.D, Region.D, Region.D,...
## $ povertyPercent <dbl> 13.8, 9.8, 30.9, 21.8, 13.2, 42.5, 24.5...
## $ cluster_group <fct> C1, C1, C1, C1, C1, C3, C2, C1, C1, C1,...
In this preliminary analysis, we compare the performance of multinomial regression with several multi-class predictive models. The goal here is to examine an appropriate algorithm for examining which factors impact the shape of the outbreak and hence, its cluster assignment. In the preliminary analysis, we will use a training (with cross validation) for model selection and a holdout dataset to evaluate the predictive performance of the different models. Given that the data is imbalanced, we will use down-sampling to account for the class imbalance problem. The list of models chosen for the preliminary analysis are highlighted below:
# [1] Training the Classifiers
# ----------------------------
trainRowNums = createDataPartition(multiClassData$cluster_group, p = 0.8, list = F) %>%
as.vector() # index rows such that approximately 80% of each class are selected
trainData = multiClassData[trainRowNums, 5:13] # training set using the above indices
testData = multiClassData[-trainRowNums, 5:13] # testing set excluding the above indices
fitControl = trainControl(method = "cv", # bootstrap sampling
number = 5, # 5 folds
summaryFunction = multiClassSummary, # using multiclass metrics
classProbs = TRUE, # saving each of the class probabilities
savePredictions = "final", # saving final predictions
selectionFunction = "best", # picking best model
sampling = "down", # to handle class imbalance in training
index = createResample(trainData$cluster_group, times = 5))
numCores = detectCores() - 1 # to allow for the use of other programs on machine while running
cl = makePSOCKcluster(numCores, outfile ="../Data/mulitClasslLog.txt")
registerDoParallel(cl)
# We set the tuneLength to 30 (i.e., # combinations of model's input parameter values to be searched)
models = caretList(y = trainData$cluster_group,
x = trainData[,-9],
tuneList = list( # defining each algorithm
cart = caretModelSpec(method = "rpart", tuneLength = 30),
multi = caretModelSpec(method = "multinom", tuneLength = 30),
nb = caretModelSpec(method="naive_bayes", tuneLength = 30),
nnet = caretModelSpec(method = 'avNNet', tuneLength = 30)),
trControl = fitControl, # see fitControl
continue_on_fail = T, # skip to next model if current did not converge
preProcess = c("scale", "center") # pre-processing parameters
)
## # weights: 72 (51 variable)
## initial value 1358.568474
## iter 10 value 1064.166790
## iter 20 value 1004.658051
## iter 30 value 975.604051
## iter 40 value 971.343074
## iter 50 value 964.921537
## iter 60 value 963.093318
## iter 70 value 960.805050
## iter 80 value 960.780645
## final value 960.780596
## converged
stopCluster(cl)
cvResults = resamples(models) # summarizing training results for each bootstrap sample * ML method
bwplot(cvResults, # boxplot of CV results
scales = list(x=list(relation="free"), y=list(relation="free")) )
# [2] Evaluation Results:
# -----------------------
xTest = subset(testData, select = -c(cluster_group))
fullResultsList = lapply(models, predict, xTest, type = "raw") %>%
lapply(confusionMatrix, testData$cluster_group)
fullResultsList %>% lapply("[[", "table") -> listConfMatrices # for each method
fullResultsList %>% lapply("[[", "byClass") -> listByClassMetrics # for each method
fullResultsList %>% lapply("[[", "overall") %>%
as.data.frame() %>% dplyr::slice(c(1,2)) -> dfOverallResults # acc + Kappa for each method
row.names(dfOverallResults) = c("Accuracy", "Kappa")
print(dfOverallResults) # printing overall results for a quick inspection of different models
## cart multi nb nnet
## Accuracy 0.5024470 0.5448613 0.5171289 0.5367047
## Kappa 0.3343788 0.3740388 0.3414655 0.3620129
Based on the results from both the cross validation and holdout set, we will use multinomial regression to further explore the data. The goal, here, is not to build a predictive model, but rather an explanatory model (see Shmueli & others (2010) for a detailed explanation of the differences). Hence, we will run the multinom() function/model on our entire dataset.
df = multiClassData %>% select(-c(id, key_numeric, administrative_area_level_2, administrative_area_level_3)) # removing these variables
# setting the reference level to category with max frequency
df$clustReLeveled = relevel(df$cluster_group, ref = maxCat(df$cluster_group) )
df = df %>% select(-c(cluster_group)) # removed since we created a reLeveled version and stored it in a diff va
finalModel = multinom(clustReLeveled ~ ., data = df) # create model
## # weights: 72 (51 variable)
## initial value 4257.309983
## iter 10 value 3728.919227
## iter 20 value 3263.770569
## iter 30 value 3020.764668
## iter 40 value 2985.246289
## iter 50 value 2969.900011
## iter 60 value 2963.117643
## final value 2963.107441
## converged
stargazer(finalModel, type = 'html', p.auto = FALSE, out="../Data/multi.html", single.row = TRUE) # tabulating the results
| Dependent variable: | |||
| C1 | C2 | C4 | |
| (1) | (2) | (3) | |
| countyTypeRural/Underserved | -0.698*** (0.140) | -0.367* (0.197) | -0.342*** (0.124) |
| popDensity | 0.005*** (0.001) | 0.005*** (0.001) | 0.004*** (0.001) |
| percRepVotes | -0.038*** (0.004) | -0.049*** (0.005) | -0.007* (0.004) |
| governorsPartyDemocratic | -0.697*** (0.132) | -0.128 (0.169) | -0.031 (0.107) |
| PercentSeniors | -0.061*** (0.011) | -0.109*** (0.017) | -0.052*** (0.010) |
| icuBedsPer10000Residents | 0.035 (0.026) | -0.148*** (0.052) | 0.025 (0.025) |
| regionsRegion.G | -3.470*** (0.267) | -0.416* (0.239) | 0.741*** (0.141) |
| regionsRegion.E | -2.929*** (0.187) | -0.319* (0.189) | 0.523*** (0.131) |
| regionsRegion.B | -2.111*** (0.220) | 1.084*** (0.202) | 0.099 (0.186) |
| regionsRegion.H | -4.007*** (0.281) | -1.564*** (0.273) | -0.361** (0.156) |
| regionsRegion.I | -0.245 (0.237) | -0.882*** (0.075) | -0.958*** (0.107) |
| regionsRegion.A | -4.973*** (0.077) | 0.745*** (0.239) | -1.517*** (0.290) |
| regionsRegion.F | -1.045*** (0.149) | -1.070*** (0.271) | -0.175 (0.156) |
| regionsRegion.D | 0.355* (0.186) | 0.346 (0.281) | 1.164*** (0.189) |
| regionsRegion.J | -1.270*** (0.247) | -9.786*** (0.00001) | 0.155 (0.235) |
| povertyPercent | -0.055*** (0.009) | -0.036*** (0.013) | -0.022** (0.009) |
| Constant | 6.225*** (0.204) | 5.059*** (0.166) | 1.732*** (0.255) |
| Akaike Inf. Crit. | 6,028.215 | 6,028.215 | 6,028.215 |
| Note: | p<0.1; p<0.05; p<0.01 | ||
summary(finalModel) # print the model's summary information using base R
## Call:
## multinom(formula = clustReLeveled ~ ., data = df)
##
## Coefficients:
## (Intercept) countyTypeRural/Underserved popDensity percRepVotes
## C1 6.224663 -0.6979852 0.005104341 -0.038026624
## C2 5.058889 -0.3670983 0.005133531 -0.048941718
## C4 1.732293 -0.3417958 0.003987863 -0.006999592
## governorsPartyDemocratic PercentSeniors icuBedsPer10000Residents
## C1 -0.69682915 -0.06063692 0.03478060
## C2 -0.12758584 -0.10903953 -0.14815709
## C4 -0.03145034 -0.05212095 0.02526057
## regionsRegion.G regionsRegion.E regionsRegion.B regionsRegion.H
## C1 -3.4702220 -2.9294779 -2.11053751 -4.0070884
## C2 -0.4161292 -0.3194404 1.08414814 -1.5643005
## C4 0.7414634 0.5234264 0.09937393 -0.3609355
## regionsRegion.I regionsRegion.A regionsRegion.F regionsRegion.D
## C1 -0.2454618 -4.9728523 -1.0454606 0.3554071
## C2 -0.8820907 0.7454172 -1.0702149 0.3464903
## C4 -0.9584420 -1.5170724 -0.1747167 1.1639031
## regionsRegion.J povertyPercent
## C1 -1.2698536 -0.05528162
## C2 -9.7856232 -0.03587532
## C4 0.1545669 -0.02207717
##
## Std. Errors:
## (Intercept) countyTypeRural/Underserved popDensity percRepVotes
## C1 0.2039747 0.1401459 0.0007591763 0.003825053
## C2 0.1657917 0.1969276 0.0007610773 0.005283180
## C4 0.2554719 0.1240128 0.0007713040 0.003818440
## governorsPartyDemocratic PercentSeniors icuBedsPer10000Residents
## C1 0.1315985 0.010540324 0.02553180
## C2 0.1692406 0.016531193 0.05186557
## C4 0.1065942 0.009719506 0.02488385
## regionsRegion.G regionsRegion.E regionsRegion.B regionsRegion.H
## C1 0.2669215 0.1870562 0.2196251 0.2814678
## C2 0.2385760 0.1893055 0.2019558 0.2728587
## C4 0.1409828 0.1309329 0.1862903 0.1557957
## regionsRegion.I regionsRegion.A regionsRegion.F regionsRegion.D
## C1 0.23716574 0.07700811 0.1490590 0.1856430
## C2 0.07451575 0.23918721 0.2710558 0.2806793
## C4 0.10734075 0.28986246 0.1564897 0.1890512
## regionsRegion.J povertyPercent
## C1 2.474614e-01 0.009393641
## C2 1.355786e-05 0.013099513
## C4 2.351644e-01 0.009003853
##
## Residual Deviance: 5926.215
## AIC: 6028.215
z = summary(finalModel)$coefficients / summary(finalModel)$standard.errors # computing z-scores
round(z, 3) %>% as.data.frame() %>% rmarkdown::paged_table() # printing it nicely with paged_table()
p = (1 - pnorm(abs(z), mean = 0, sd = 1) ) * 2 # computing p
round(p, 3) %>% as.data.frame() %>% rmarkdown::paged_table() # printing it nicely
predictedProbs = fitted(finalModel) # computing predicted probabilities for each of the three cluster outcome levels
multiClassResults = cbind(na.omit(multiClassData), predictedProbs) %>% # column binding the objects predictedProbs with multiClassData
select(-c(id, key_numeric, administrative_area_level_2, administrative_area_level_3, cluster_group)) # dropping id type columns
# Finding indices for subsetting data
numberOfClusters = unique(multiClassData$cluster_group) %>%
as.character() %>% length() # automatically finding the number of clusters in our best model
startCol = ncol(multiClassResults) - numberOfClusters + 1
endCol = ncol(multiClassResults)
# DF for Cat Data
multiClassCat = multiClassResults
multiClassCat$LargestProbCluster = colnames(multiClassCat[, startCol:endCol])[apply(multiClassCat[, startCol:endCol], 1, which.max)]
# DF for Line Plots
multiClassResults = reshape2::melt(multiClassResults, id.vars = colnames(multiClassResults)[1:8],
value.name = 'probability') # convert data into a long format
# Ensuring consistent colors with previous plots
colorPal = brewer.pal(n=numberOfClusters, 'Set2')
names(colorPal) = levels(multiClassData$cluster_group)
# Creating a summary Table for numeric variables based on each combination of all categorical variables
resSummary = multiClassResults %>% group_by(variable, regions, governorsParty, countyType) %>%
summarise_all(mean) # creating a means Summary Table to Make visualizations meaningful
resSummary %>% rmarkdown::paged_table()
ggplot(resSummary, aes(x = popDensity, y = probability, color = variable)) + # setting the x-axis, y-axis, and color
geom_line() + facet_grid(variable ~ .) +
scale_color_manual(name = "Predicted Cluster", values = colorPal) +
scale_y_continuous(limits = c(0,1)) + # color and y-axis limits
labs(x = 'Population Density', y = 'Probability of Prediction from Multinomial Model') + theme_bw() + theme(legend.position = 'bottom')
ggplot(resSummary, aes(x = percRepVotes, y = probability, color = variable)) + # setting the x-axis, y-axis, and color
geom_line() + facet_grid(variable ~ .) +
scale_color_manual(name = "Predicted Cluster", values = colorPal) +
scale_y_continuous(limits = c(0,1)) + # color and y-axis limits
labs(x = '% Republican Votes in 2016 Presidential Election',
y = 'Probability of Prediction from Multinomial Model') +
theme_bw() + theme(legend.position = 'bottom')
ggplot(resSummary, aes(x = PercentSeniors, y = probability, color = variable)) + # setting the x-axis, y-axis, and color
geom_line() + facet_grid(variable ~ .) +
scale_color_manual(name = "Predicted Cluster", values = colorPal) +
scale_y_continuous(limits = c(0,1)) + # color and y-axis limits
labs(x = '% Seniors', y = 'Probability of Prediction from Multinomial Model') + theme_bw() + theme(legend.position = 'bottom')
ggplot(resSummary, aes(x = icuBedsPer10000Residents, y = probability, color = variable)) + # setting the x-axis, y-axis, and color
geom_line() + facet_grid(variable ~ .) +
scale_color_manual(name = "Predicted Cluster", values = colorPal) +
scale_y_continuous(limits = c(0,1)) + # color and y-axis limits
labs(x = '# ICU Beds Per 10,000 Residents', y = 'Probability of Prediction from Multinomial Model') + theme_bw() + theme(legend.position = 'bottom')
ggplot(resSummary, aes(x = povertyPercent, y = probability, color = variable)) + # setting the x-axis, y-axis, and color
geom_line() + facet_grid(variable ~ .) +
scale_color_manual(name = "Predicted Cluster", values = colorPal) +
scale_y_continuous(limits = c(0,1)) + # color and y-axis limits
labs(x = 'Percent Poverty', y = 'Probability of Prediction from Multinomial Model') + theme_bw() + theme(legend.position = 'bottom')
multiClassCat %>% select(c(LargestProbCluster, regions)) %>% # selecting the two columns of interest
group_by(LargestProbCluster, regions) %>% count() %>% # counting occurrences of combinations of these columns
ggplot(aes(x = factor(regions, levels = paste0(rep('Region.', 10), head(LETTERS, 10))),
y = n, fill = LargestProbCluster, group = LargestProbCluster)) +
geom_bar(stat="identity") +
geom_text(aes(label = n), position="stack", vjust= 0, hjust = 1.25, col="black", size=2) +
scale_fill_manual(name = "Predicted Cluster", values = colorPal) + coord_flip() +
labs(x = 'Regions', y = 'Frequency') + theme_bw() + theme(legend.position = 'bottom')
multiClassCat %>% select(c(LargestProbCluster, governorsParty)) %>% # selecting the two columns of interest
group_by(LargestProbCluster, governorsParty) %>% count() %>% # counting occurrences of combinations of these columns
ggplot(aes(x = governorsParty, y = n, fill = LargestProbCluster, group = LargestProbCluster)) +
geom_bar(stat="identity") +
geom_text(aes(label = n), position="stack", vjust= 0, hjust = 1.25, col="black", size=2) +
scale_fill_manual(name = "Predicted Cluster", values = colorPal) + coord_flip() +
labs(x = "Governor's Party", y = 'Frequency') + theme_bw() + theme(legend.position = 'bottom')
multiClassCat %>% select(c(LargestProbCluster, countyType)) %>% # selecting the two columns of interest
group_by(LargestProbCluster, countyType) %>% count() %>% # counting occurrences of combinations of these columns
ggplot(aes(x = countyType, y = n, fill = LargestProbCluster, group = LargestProbCluster)) +
geom_bar(stat="identity") +
geom_text(aes(label = n), position="stack", vjust= 0, hjust = 1.25, col="black", size=2) +
scale_fill_manual(name = "Predicted Cluster", values = colorPal) + coord_flip() +
labs(x = "County Type", y = 'Frequency') + theme_bw() + theme(legend.position = 'bottom')
In the chunk below, we answer the question which counties were correctly predicted by the multinomial regression model (i.e., the classification results from the multinomial regression model matched the cluster assignment from the \(k\)-means clustering algorithm). The map below is interactive to allow the reader to zoom, and click on a county to obtain (relevant information).
mapResults = cbind(na.omit(multiClassData), predictedProbs) # we need the ids for this
startCol = ncol(mapResults) - numberOfClusters + 1
endCol = ncol(mapResults)
mapResults = cbind(na.omit(multiClassData), predictedProbs) %>%
mutate(key_numeric = str_pad(key_numeric, width = 5, side = 'left', pad = '0') %>% as.factor())
# Appending Columns to Map Results and Transforming key-numeric to a proper FIPS_Code
mapResults$key_numeric %<>% str_pad(width = 5, side = 'left', pad = '0') %>% as.factor()
mapResults$LargestProbCluster = colnames(mapResults[, startCol:endCol])[apply(mapResults[, startCol:endCol], 1, which.max)]
mapResults$match = ifelse(mapResults$cluster_group == mapResults$LargestProbCluster, 'Yes', 'No') %>% as.factor()
cty_sf_joined <- cty_sf %>% geo_join(mapResults, by_sp = "fips", by_df = "key_numeric")
myPal = colorFactor('Paired', domain = cty_sf_joined$match, na.color = "white")
leaflet(height=500) %>% # initializing the leaflet map
setView(lng = -96, lat = 37.8, zoom = 3.8) %>% # setting the view on Continental US
addTiles() %>% # adding the default tiles
addPolygons(data = cty_sf, stroke = FALSE, fillColor = ~myPal(cty_sf_joined$match), # adding the data
weight = 2, opacity = 1, color = "white", dashArray = "3", fillOpacity = 0.7, # adding color specs
popup = paste("County:", cty_sf_joined$name, '<br>',
"Cluster #:", cty_sf_joined$cluster_group, '<br>',
'Cluster Pred from Multinomial:', cty_sf_joined$LargestProbCluster, '<br>',
"Population Density:", round(cty_sf_joined$popDensity, 1), '<br>',
"Poverty %:", round(cty_sf_joined$povertyPercent, 1), '<br>')) %>% #pop-up Menu
addLegend(position = "bottomleft", pal = myPal, values = cty_sf_joined$match,
title = "Cluster Match", opacity = 1) # legend formatting
In the chunk below, we answer the question which counties were correctly predicted by the multinomial regression model (i.e., the classification results from the multinomial regression model matched the cluster assignment from the \(k\)-means clustering algorithm). As opposed to the previous map, this is a static map that can be easily exported into traditional presentations and written reports.
cty_sf_joined %<>% filter(!state %in% c('Alaska', 'Hawaii'))
d3map2 = d3_map(shape = cty_sf_joined, projection = "Albers") %>%
add_discrete_scale(var = "match", palette = "Paired") %>%
add_legend(title = "Cluster #")
# saving output as a static png to be used in the paper
# Using the save_d3_png() function requires that you install the webshot package, as well as the
# phantom.js headless browser (which you can install using the function webshot::install_phantomjs()).
r2d3::save_d3_png(d3map2, file = '../Figures/CountyMatches.png', width = 1366, height = 768)
d3map2 # printing it out for the markdown
In the code chunk below, we compute the percentage of correctly matched results (i.e., cluster results were correctly predicted by the multinomial regression model) by state.
#Repeating from previous chunks since we overwrote the object
mapResults = cbind(na.omit(multiClassData), predictedProbs)
mapResults$LargestProbCluster = colnames(mapResults[, startCol:endCol])[apply(mapResults[, startCol:endCol], 1, which.max)]
mapResults$match = ifelse(mapResults$cluster_group == mapResults$LargestProbCluster, 1, 0)
# grouping the object by state
mapResults %>% group_by(administrative_area_level_2) %>%
summarise(perCorrect = 100* round(sum(match)/ n(), 2) ) %>% # %counties that were correctly predicted by multinom model by state
rmarkdown::paged_table(options = list(rows.print = 10)) # print the results
In the code chunk below, we summarize the matched groups by cluster. Recall that cluster_group denotes the cluster assigned to a given county from the \(k\)-means clustering approach and the largestProbCluster denotes the cluster prediction from the multinomial model.
mapResults %>% group_by(cluster_group, LargestProbCluster) %>%
summarise(n = n()) %>%
rmarkdown::paged_table()
We also tabulate the total of correctly matched results (i.e., cluster results were correctly predicted by the multinomial regression model). Note that 1 corresponds to a correct match and 0 corresponds to a mismatch.
table(mapResults$match)
##
## 0 1
## 1267 1804
In this R Markdown document, we have shown that our proposed two stage framework for modeling the smoothed and scaled time series of new daily cases can provide insights into the shape of the outbreak’s time-series and some of its associated factors. Specifically, we have shown that:
On a county-level, the time series of COVID-19 new daily cases can be clustered into 4 clusters.
Using a multinomial regression model, we have shown/quantified the impact of the following factors: (a) county type (rural/underserved vs not), (b) population density, (c) percentage of the county’ population voting Republican in the 2016 Presidential Elections, (d) the affiliation of the state’s governor [mayor in case of the District of Columbia], (e) percentage of seniors in the county, (f) the number of ICU beds per 10,000 Residents within the county, (g) the CDC region’s categorization of the state, and (h) percent of the county’s resident population in poverty on the odds of being in a specific cluster when compared to the baseline.
Aghabozorgi, S., Shirkhorshidi, A. S., & Wah, T. Y. (2015). Time-series clustering–a decade review. Information Systems, 53, 16–38.
Charrad, M., Ghazzali, N., Boiteau, V., & Niknafs, A. (2014). NbClust: An r package for determining the relevant number of clusters in a data set. Journal of Statistical Software, Articles, 61(6), 1–36. https://doi.org/10.18637/jss.v061.i06
Data, M. E., & Lab, S. (2018). County Presidential Election Returns 2000-2016 (Version V6) [Data set]. Harvard Dataverse. https://doi.org/10.7910/DVN/VOQCHQ
Guidotti, E., & Ardia, D. (2020). COVID-19 data hub. Journal of Open Source Software, 5(51), 2376. https://doi.org/10.21105/joss.02376
Sardá-Espinosa, A. (2017). Comparing time-series clustering algorithms in r using the dtwclust package. R Package Vignette, 12, 41.
Shmueli, G., & others. (2010). To explain or to predict? Statistical Science, 25(3), 289–310.
In the appendix, we print all the R packages used in our analysis and their versions to assist with reproducing our results/analysis.
sInfo
## R version 4.0.2 (2020-06-22)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 18363)
##
## Matrix products: default
##
## Random number generation:
## RNG: L'Ecuyer-CMRG
## Normal: Inversion
## Sample: Rejection
##
## locale:
## [1] LC_COLLATE=English_United States.1252
## [2] LC_CTYPE=English_United States.1252
## [3] LC_MONETARY=English_United States.1252
## [4] LC_NUMERIC=C
## [5] LC_TIME=English_United States.1252
##
## attached base packages:
## [1] grid parallel stats graphics grDevices utils datasets
## [8] methods base
##
## other attached packages:
## [1] conflicted_1.0.4 naivebayes_0.9.7 nnet_7.3-14
## [4] rpart_4.1-15 MLmetrics_1.1.1 DMwR_0.4.1
## [7] caTools_1.18.0 AUC_0.3.0 caretEnsemble_2.0.1
## [10] caret_6.0-86 lattice_0.20-41 rgeos_0.5-5
## [13] choroplethrMaps_1.0.1 choroplethr_3.7.0 acs_2.1.4
## [16] XML_3.99-0.5 leaflet_2.0.3 GGally_2.0.0
## [19] raster_3.3-13 sp_1.4-4 RColorBrewer_1.1-2
## [22] gridExtra_2.3 ggdendro_0.1.22 scales_1.1.1
## [25] DataExplorer_0.8.1 NbClust_3.0 TSclust_1.3.1
## [28] cluster_2.1.0 pdc_1.0.3 factoextra_1.0.7
## [31] dtwclust_5.5.6 dtw_1.22-3 proxy_0.4-24
## [34] expsmooth_2.3 fma_2.4 forecast_8.13
## [37] fpp2_2.4 zoo_1.8-8 stargazer_5.2.2
## [40] DT_0.16 readxl_1.3.1 rvest_0.3.6
## [43] xml2_1.3.2 COVID19_2.3.1 reshape2_1.4.4
## [46] VIM_6.0.0 colorspace_1.4-1 skimr_2.1.2
## [49] psych_2.0.9 doParallel_1.0.16 iterators_1.0.13
## [52] foreach_1.5.1 recipes_0.1.14 dataPreparation_0.4.3
## [55] progress_1.2.2 Matrix_1.2-18 lubridate_1.7.9
## [58] magrittr_1.5 forcats_0.5.0 stringr_1.4.0
## [61] dplyr_1.0.2 purrr_0.3.4 readr_1.4.0
## [64] tidyr_1.1.2 tibble_3.0.4 ggplot2_3.3.2
## [67] tidyverse_1.3.0 pacman_0.5.1
##
## loaded via a namespace (and not attached):
## [1] rappdirs_0.3.1 ModelMetrics_1.2.2.2 knitr_1.30
## [4] data.table_1.13.2 generics_0.0.2 webshot_0.5.2
## [7] httpuv_1.5.4 assertthat_0.2.1 gower_0.2.2
## [10] xfun_0.18 hms_0.5.3 evaluate_0.14
## [13] promises_1.1.1 DEoptimR_1.0-8 fansi_0.4.1
## [16] dbplyr_1.4.4 igraph_1.2.6 DBI_1.1.0
## [19] tmvnsim_1.0-2 quantmod_0.4.17 htmlwidgets_1.5.2
## [22] reshape_0.8.8 stats4_4.0.2 ellipsis_0.3.1
## [25] RSpectra_0.16-0 crosstalk_1.1.0.1 backports_1.1.10
## [28] RcppParallel_5.0.2 vctrs_0.3.4 ROCR_1.0-11
## [31] TTR_0.24.2 abind_1.4-5 withr_2.3.0
## [34] tigris_1.0 robustbase_0.93-6 checkmate_2.0.0
## [37] rgdal_1.5-18 vcd_1.4-8 ggmap_3.0.0
## [40] xts_0.12.1 prettyunits_1.1.1 mnormt_2.0.2
## [43] bigmemory_4.5.36 urca_1.3-0 laeken_0.5.1
## [46] crayon_1.3.4 tidycensus_0.10.2 pkgconfig_2.0.3
## [49] units_0.6-7 nlme_3.1-149 rlang_0.4.8
## [52] RJSONIO_1.3-1.4 lifecycle_0.2.0 miniUI_0.1.1.1
## [55] bigmemory.sri_0.1.3 modelr_0.1.8 cellranger_1.1.0
## [58] tcltk_4.0.2 lmtest_0.9-38 carData_3.0-4
## [61] boot_1.3-25 reprex_0.3.0 base64enc_0.1-3
## [64] png_0.1-7 rjson_0.2.20 bitops_1.0-6
## [67] KernSmooth_2.23-17 pROC_1.16.2 blob_1.2.1
## [70] rgl_0.100.54 classInt_0.4-3 manipulateWidget_0.10.1
## [73] maptools_1.0-2 jpeg_0.1-8.1 memoise_1.1.0
## [76] plyr_1.8.6 compiler_4.0.2 clue_0.3-57
## [79] cli_2.1.0 pbapply_1.4-3 htmlTable_2.1.0
## [82] Formula_1.2-4 MASS_7.3-53 tidyselect_1.1.0
## [85] stringi_1.5.3 tseries_0.10-47 yaml_2.2.1
## [88] latticeExtra_0.6-29 clv_0.3-2.2 ggrepel_0.8.2
## [91] tools_4.0.2 rio_0.5.16 RgoogleMaps_1.4.5.3
## [94] rstudioapi_0.11 uuid_0.1-4 foreign_0.8-80
## [97] prodlim_2019.11.13 digest_0.6.26 longitudinalData_2.4.1
## [100] shiny_1.5.0 flexclust_1.4-0 lava_1.6.8
## [103] quadprog_1.5-8 networkD3_0.4 Rcpp_1.0.5
## [106] car_3.0-10 broom_0.7.2 later_1.1.0.1
## [109] httr_1.4.2 WDI_2.7.1 sf_0.9-6
## [112] fs_1.5.0 ranger_0.12.1 splines_4.0.2
## [115] xtable_1.8-4 jsonlite_1.7.1 nloptr_1.2.2.2
## [118] timeDate_3043.102 modeltools_0.2-23 ipred_0.9-9
## [121] R6_2.4.1 Hmisc_4.4-1 pillar_1.4.6
## [124] htmltools_0.5.0 mime_0.9 glue_1.4.2
## [127] fastmap_1.0.1 class_7.3-17 codetools_0.2-16
## [130] curl_4.3 locpol_0.7-0 misc3d_0.9-0
## [133] zip_2.1.1 shinyjs_2.0.0 openxlsx_4.2.2
## [136] survival_3.2-7 rmarkdown_2.5 repr_1.1.0
## [139] munsell_0.5.0 e1071_1.7-4 haven_2.3.1
## [142] fracdiff_1.5-1 gtable_0.3.0
Email: fmegahed@miamioh.edu | Phone: +1-513-529-4185 | Website: Miami University Official↩︎
Email: farmerl2@miamioh.edu | Phone: +1-513-529-4823 | Website: Miami University Official↩︎
Email: steve.rigdon@slu.edu | Website: Saint Louis University Official↩︎